/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lomanda
 */
@Entity
@Table(name = "projeto")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Projeto.findAll", query = "SELECT p FROM Projeto p"),
    @NamedQuery(name = "Projeto.findByIdObra", query = "SELECT p FROM Projeto p WHERE p.idObra = :idObra"),
    @NamedQuery(name = "Projeto.findByTitulo", query = "SELECT p FROM Projeto p WHERE p.titulo = :titulo"),
    @NamedQuery(name = "Projeto.findByDescricao", query = "SELECT p FROM Projeto p WHERE p.descricao = :descricao"),
    @NamedQuery(name = "Projeto.findByResponsavel", query = "SELECT p FROM Projeto p WHERE p.responsavel = :responsavel"),
    @NamedQuery(name = "Projeto.findByDataInicial", query = "SELECT p FROM Projeto p WHERE p.dataInicial = :dataInicial"),
    @NamedQuery(name = "Projeto.findByDataFinal", query = "SELECT p FROM Projeto p WHERE p.dataFinal = :dataFinal"),
    @NamedQuery(name = "Projeto.findByEntrega", query = "SELECT p FROM Projeto p WHERE p.entrega = :entrega")})
public class Projeto implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataInicial")
    @Temporal(TemporalType.DATE)
    private Date dataInicial;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataFinal")
    @Temporal(TemporalType.DATE)
    private Date dataFinal;
    @Column(name = "entrega")
    @Temporal(TemporalType.DATE)
    private Date entrega;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idObra")
    private Integer idObra;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "titulo")
    private String titulo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "descricao")
    private String descricao;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "responsavel")
    private String responsavel;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkObra")
    private List<Album> albumList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkObra")
    private List<Anotacoes> anotacoesList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkObra")
    private List<ContratoObra> contratoObraList;
    @JoinColumn(name = "fkUsuario", referencedColumnName = "idUsuario")
    @ManyToOne(optional = false)
    private Usuario fkUsuario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkObra")
    private List<DetalhesProjeto> detalhesProjetoList;

    public Projeto() {
    }

    public Projeto(Integer idObra) {
        this.idObra = idObra;
    }

    public Projeto(Integer idObra, String titulo, String descricao, String responsavel, Date dataInicial, Date dataFinal) {
        this.idObra = idObra;
        this.titulo = titulo;
        this.descricao = descricao;
        this.responsavel = responsavel;
        this.dataInicial = dataInicial;
        this.dataFinal = dataFinal;
    }

    public Integer getIdObra() {
        return idObra;
    }

    public void setIdObra(Integer idObra) {
        this.idObra = idObra;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public String getResponsavel() {
        return responsavel;
    }

    public void setResponsavel(String responsavel) {
        this.responsavel = responsavel;
    }

    @XmlTransient
    public List<Album> getAlbumList() {
        return albumList;
    }

    public void setAlbumList(List<Album> albumList) {
        this.albumList = albumList;
    }

    @XmlTransient
    public List<Anotacoes> getAnotacoesList() {
        return anotacoesList;
    }

    public void setAnotacoesList(List<Anotacoes> anotacoesList) {
        this.anotacoesList = anotacoesList;
    }

    @XmlTransient
    public List<ContratoObra> getContratoObraList() {
        return contratoObraList;
    }

    public void setContratoObraList(List<ContratoObra> contratoObraList) {
        this.contratoObraList = contratoObraList;
    }

    public Usuario getFkUsuario() {
        return fkUsuario;
    }

    public void setFkUsuario(Usuario fkUsuario) {
        this.fkUsuario = fkUsuario;
    }

    @XmlTransient
    public List<DetalhesProjeto> getDetalhesProjetoList() {
        return detalhesProjetoList;
    }

    public void setDetalhesProjetoList(List<DetalhesProjeto> detalhesProjetoList) {
        this.detalhesProjetoList = detalhesProjetoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idObra != null ? idObra.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Projeto)) {
            return false;
        }
        Projeto other = (Projeto) object;
        if ((this.idObra == null && other.idObra != null) || (this.idObra != null && !this.idObra.equals(other.idObra))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Projeto[ idObra=" + idObra + " ]";
    }

    public Date getDataInicial() {
        return dataInicial;
    }

    public void setDataInicial(Date dataInicial) {
        this.dataInicial = dataInicial;
    }

    public Date getDataFinal() {
        return dataFinal;
    }

    public void setDataFinal(Date dataFinal) {
        this.dataFinal = dataFinal;
    }

    public Date getEntrega() {
        return entrega;
    }

    public void setEntrega(Date entrega) {
        this.entrega = entrega;
    }
    
}
